package com.filldream.fastboot.common.okutil.gz;

//import lombok.Data;
import java.io.BufferedInputStream;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.util.Scanner;

/**
 * 计算薪资
 * 一、编译执行问题
 * 1、注释掉package，然后将.java文件放到磁盘根目录下
 * 2、注释掉所有依赖，仅用jdk自带的功能写代码
 * 3、进入到.java所在的文件目录中，执行 javac -encoding UTF-8 Gz.java
 * 4、进入到.java所在的文件目录中，执行 java -classpath D:\ Gz
 */
public class Gz {

    //合同薪资
    private String maxMoney;
    //试用期折扣
    private String discount;
    //电脑补贴
    private String computerSubsidy;
    //工作日
    private String workDay;

    public String getMaxMoney() {
        return maxMoney;
    }

    public void setMaxMoney(String maxMoney) {
        this.maxMoney = maxMoney;
    }

    public String getDiscount() {
        return discount;
    }

    public void setDiscount(String discount) {
        this.discount = discount;
    }

    public String getComputerSubsidy() {
        return computerSubsidy;
    }

    public void setComputerSubsidy(String computerSubsidy) {
        this.computerSubsidy = computerSubsidy;
    }

    public String getWorkDay() {
        return workDay;
    }

    public void setWorkDay(String workDay) {
        this.workDay = workDay;
    }

    public String getRealWorkDay() {
        return realWorkDay;
    }

    public void setRealWorkDay(String realWorkDay) {
        this.realWorkDay = realWorkDay;
    }

    public String getGjj() {
        return gjj;
    }

    public void setGjj(String gjj) {
        this.gjj = gjj;
    }

    public String getYlbx() {
        return ylbx;
    }

    public void setYlbx(String ylbx) {
        this.ylbx = ylbx;
    }

    public String getSy() {
        return sy;
    }

    public void setSy(String sy) {
        this.sy = sy;
    }

    public String getYl() {
        return yl;
    }

    public void setYl(String yl) {
        this.yl = yl;
    }

    public String getNs() {
        return ns;
    }

    public void setNs(String ns) {
        this.ns = ns;
    }

    //实际工作日
    private String realWorkDay;
    //公积金
    private String gjj;
    //养老保险
    private String ylbx;
    //失业保险
    private String sy;
    //医疗保险
    private String yl;
    //个人所得税
    private String ns;



    //----------------------方法区-------------------------

    /**
     * 计算薪资
     * @return
     */
    public String getRealMoney(){
        System.out.println("\r\n------------------------------------成都合一优品数字信息技术有限公司--------------------------------------------");
        //试用期/转正期工资
        BigDecimal discountMoney = new BigDecimal(maxMoney).multiply(new BigDecimal(discount));
        System.out.println("合同薪资:" + maxMoney
                + "\t" + "试用期折扣:" + discount
                +"\t工作日:" + workDay + "\t实际工作日:" + realWorkDay
        );

        //平均薪资
        BigDecimal avgMoney = discountMoney.divide(new BigDecimal(workDay), 4, BigDecimal.ROUND_HALF_UP);
        //缺勤天数
        BigDecimal absenceDay = new BigDecimal(workDay).subtract(new BigDecimal(realWorkDay));
        System.out.println("总薪资:" + discountMoney + "\t平均薪资:" + avgMoney + "\t扣除薪资:" + avgMoney.multiply(absenceDay) + "\t电脑补贴:"+computerSubsidy );

        //税前薪资
        BigDecimal beforeTaxMoney = avgMoney.multiply(new BigDecimal(realWorkDay));
        System.out.println("税前薪资:" + beforeTaxMoney + "\t实际税前:" + beforeTaxMoney.add(new BigDecimal(computerSubsidy)).setScale(0, BigDecimal.ROUND_DOWN));

        //五险一金,合计
        BigDecimal fiveInsurance = new BigDecimal(gjj).add(new BigDecimal(ylbx)).add(new BigDecimal(sy)).add(new BigDecimal(yl)).add(new BigDecimal(ns));
        System.out.println("公积金:" + gjj + "\t养老险:" + ylbx + "\t失业险:" + sy + "\t医疗险:" + yl + "\t所得税:" + ns + "\t合计:" + fiveInsurance);

        //实际收入
        BigDecimal realMoney = beforeTaxMoney.subtract(fiveInsurance).add(new BigDecimal(computerSubsidy));

        System.out.println("\r\n\t实收薪资:" + realMoney + "元");
        System.out.println("------------------------------------成都合一优品数字信息技术有限公司--------------------------------------------\r\n");
        return realMoney.toString();
    }

    /**
     * 输入参数，计算工资
     */
    public static void printGz(){
        Scanner scanner = new Scanner(System.in, "UTF-8");

        System.out.println("请输入合同薪资:");
        String maxMoney = scanner.nextLine();

        System.out.println("请输入试用期折扣:");
        String discount = scanner.nextLine();

        System.out.println("请输入电脑补贴:");
        String computerSubsidy = scanner.nextLine();

        System.out.println("请输入工作日:");
        String workDay = scanner.nextLine();

        System.out.println("请输入实际工作日:");
        String realWorkDay = scanner.nextLine();

        System.out.println("请输入公积金:");
        String gjj = scanner.nextLine();

        System.out.println("请输入养老保险:");
        String ylbx = scanner.nextLine();

        System.out.println("请输入失业保险:");
        String sy = scanner.nextLine();

        System.out.println("请输入医疗保险:");
        String yl = scanner.nextLine();

        System.out.println("请输入个人所得税:");
        String ns = scanner.nextLine();

        Gz gz = new Gz();
        gz.setMaxMoney(maxMoney);
        gz.setDiscount(discount);
        gz.setComputerSubsidy(computerSubsidy);
        gz.setWorkDay(workDay);
        gz.setRealWorkDay(realWorkDay);
        gz.setGjj(gjj);
        gz.setYlbx(ylbx);
        gz.setSy(sy);
        gz.setYl(yl);
        gz.setNs(ns);
        gz.getRealMoney();
        scanner.close();
    }


    public static void main(String[] args) {
//        Gz gz = new Gz();
//        gz.setMaxMoney("12000");
//        gz.setDiscount("0.8");
//        gz.setComputerSubsidy("100");
//        gz.setWorkDay("21");
//        gz.setRealWorkDay("20");
//        gz.setGjj("105");
//        gz.setYlbx("339.68");
//        gz.setSy("16.98");
//        gz.setYl("84.92");
//        gz.setNs("110.89");
//        gz.getRealMoney();
        printGz();
    }

}
